<html>
<head>
 
</head>
<body style="text-align=center;font-size:24px">
<div id="problemNum" style='background-color:#999999;width:400;text-align:left;'></div>
<div id="problemContent" style='background-color:#bbbbbb;width:400;text-align:left;'></div>
<div id="result" style='color:#ffff22;font-size:48;background-color:#8855ff;width:400;'></div>
 
<script language="javascript">
    //---------------------------------//
    // Project Euler 
    //
    // Author:xiaomingneo
    //   Date:2015-12-07
    //---------------------------------//  
var N=3;
var problem="The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?";
//solve the problem
var num=600851475143;
function isPrime(M){
    var tmp=Math.floor(Math.sqrt(M));
    if(M%2==0)return true;
    var i=0;
    for(i=3;i<tmp;i+=2){
        if(M%i==0)return false;
    }
    return true;
}
var tmp=Math.sqrt(num);
for(var i=3;i<tmp;i+=2){
    if(isPrime(i)&& num%i==0)maxPrime=i;
}
//update browser
document.getElementById("problemNum").innerHTML="Project Euler-Problem "+N;
document.getElementById("problemContent").innerHTML=problem;
document.getElementById("result").innerHTML="Answer:"+maxPrime;
 
</script>
</body>
</html>